from django.db import models
from dingxiang.utils.models import BaseModel
# Create your models here.

# 临床科室
class ClinicalDepartmentModel(BaseModel):
    name = models.CharField(max_length=255, verbose_name="科室名称")

    class Meta:
        db_table = 'clinical_department'
        verbose_name_plural = '临床科室'

    def __str__(self):
        return self.name

# 临床指南
class ClinicalGuidelinesModel(BaseModel):
    title = models.CharField(max_length=255, verbose_name="指南标题")
    clinical_department = models.ManyToManyField(ClinicalDepartmentModel, null=True, blank=True, verbose_name='临床科室')

    class Meta:
        db_table = 'clinical_guidelines'
        verbose_name_plural = '临床指南'

    def __str__(self):
        return self.title

# 临床指南内容
class ClinicalGuidelineContentModel(BaseModel):
    # 标题
    title = models.CharField(max_length=100, null=True, verbose_name='标题')
    # 发布日期
    release_date = models.DateField(auto_now_add=True, null=True, blank=True, verbose_name='发布日期')
    # 制定者
    Maker = models.CharField(max_length=200, null=True, verbose_name='制定者')
    # 来源
    source = models.CharField(max_length=500, null=True, verbose_name='来源')
    # 概述
    summary = models.CharField(max_length=500, null=True, verbose_name='概述')
    # 临床指南
    clinical_guidelines = models.ForeignKey(ClinicalGuidelinesModel, null=True, on_delete=models.CASCADE, related_name='contents', verbose_name="临床指南")
    recomment_home = models.BooleanField(default=False, null=True, verbose_name='是否推荐首页栏目')

    class Meta:
        db_table = 'clinical_guideline_content'
        verbose_name_plural = '临床指南内容'

    def __str__(self):
        return self.title
